package com.xncoding.easypoi.util;

import java.util.ArrayList;
import java.util.List;

import com.xncoding.easypoi.model.BusinessData;
import org.apache.log4j.Logger;

public class Test {


    public static Logger log = Logger.getLogger(Test.class);


    public  String createPDF(Object data, String fileName){
        try {
            PDFUtils pdfUtils=new PDFUtils();
            String saveFilePath=pdfUtils.exportToFile("D:/ho.pdf","D:/java/workspace/idea/springboot-bucket/springboot-easypoi/src/main/resources/template/hello.ftl",data,false);
            return  saveFilePath;
        } catch (Exception e) {
            e.printStackTrace();
            log.error("PDF生成失败{}");
            return null;
        }
    }

    public static void main(String[] args) {
        Test kit=new Test();
        BusinessData businessData=new BusinessData();
        businessData.setTemplateName("Hello iText! Hello freemarker! Hello jFreeChart!");
        businessData.setFreeMarkerUrl("http://www.zheng-hang.com/chm/freemarker2_3_24/ref_directive_if.html");
        businessData.setITEXTUrl("http://developers.itextpdf.com/examples-itext5");
        businessData.setJFreeChartUrl("http://www.yiibai.com/jfreechart/jfreechart_referenced_apis.html");
        businessData.setImageUrl("E:/哈.png");
        businessData.setPicUrl("E:/哈.png");
        List<String> scores=new ArrayList<String>();
        for (int i = 0; i < 100; i++) {

            scores.add("94"+i);
            scores.add("95"+i);
            scores.add("98"+i);
        }
        businessData.setScores(scores);
        String path= kit.createPDF(businessData,"hello.pdf");
        System.out.println("打印："+path);
    }
}
